jQuery(function($){
	var supplierSettlementDetail={
			grid : null,
			init:function(){
				this.checkState=[
								    {value:1,text:"采购单"},
								    {value:2,text:"采购退货单"}
				];	
				var url="supplierSettlementDetailPageList.do";
				var parms=[
							{name: "settlementNo", value:$("#settlementNo").val()}
		                    ];
				var columns=[
					            { display: '结算编号', name: 'settlementNo',width:'80'},
					            { display: '采购单编号', name: 'poNo'},
					            /*{ display: '采购单名称', name: 'poName',width:'500'},*/
					            { display: '采购单类型', name: 'poType',
					            	render: function (rowdata, rowindex, value){
					            		return supplierSettlementDetail.getTextByValue(supplierSettlementDetail.checkState,value);
					            	}
					            },
					            { display: '总价(元)', name: 'totalPrice',width:'80',render:
					            	function (rowdata, rowindex, value){
					            	    if(rowdata.poType==1){
				            				return value?parseFloat(value).toFixed(2):"0";
					            	    }else{
				            				return value?(parseFloat(-value).toFixed(2)):"0";
					            	    }
					            	}
		            			},
					            { display: '采购数量', name: 'returnQuantity',width:'80'}
				            ];
				var config={};
				config.url=url;
				config.columns=columns;
				config.parms=parms;
				this.pageList(config);
			},
			pageList:function(config){
				supplierSettlementDetail.grid = $("#maingrid").ligerGrid({
		            columns: config.columns, 
		            pageSize:30,
		            width: '100%',
		            height: '100%',
		            dataType: 'server', 
		            dataAction: 'server',
		            pagesizeParmName: 'pageSize',
		            parms:config.parms ,
					url: config.url,
					toolbar: toolbar
		        });
				grid=supplierSettlementDetail.grid;
			},
			setSelectBox:function(config){
				$.ajax({
					url:basePath+config.url,
					type:"post",
					dataType:"json",
					success:function(result){
						if(result  && result.length){
							config.dom.html('<option value="">请选择</option>');
							for(var x in result){
								config.dom.append('<option value="'+result[x][config.value]+'">'+result[x][config.text]+'</option>');
							}
						}
					}
				});
			},
			getTextByValue:function(objs,value){
				if(objs && objs.length){
					for(var x in objs){
						if(objs[x].value==value){
							return objs[x].text;
						}
					}
				}
			}
	};
	supplierSettlementDetail.init();
}); 